Skip to content

dw2elf: fix compilation errors — add dwarf.h, fix AT_name_a arg count#132

Merged
staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd
May 21, 2026
Merged

dw2elf: fix compilation errors — add dwarf.h, fix AT_name_a arg count#132
staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd

Conversation

@staalmannen

Copy link
Copy Markdown
Owner
  • Add #include <dwarf.h> to get DW_TAG_compile_unit, DW_TAG_subprogram, DW_TAG_formal_parameter constants (not exported via libdwarfp.h alone)
  • Fix all dwarf_add_AT_name_a() calls: signature requires 4 args (die, name, Dwarf_P_Attribute *outattr, Dwarf_Error *error) not 3

https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs

- Add #include <dwarf.h> to get DW_TAG_compile_unit, DW_TAG_subprogram,
  DW_TAG_formal_parameter constants (not exported via libdwarfp.h alone)
- Fix all dwarf_add_AT_name_a() calls: signature requires 4 args
  (die, name, Dwarf_P_Attribute *outattr, Dwarf_Error *error) not 3

https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
@staalmannen staalmannen merged commit 4e2b0cc into main May 21, 2026
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates dw2elf.c to include the dwarf.h header and modifies dwarf_add_AT_name_a calls to include a mandatory Dwarf_P_Attribute parameter. Feedback was provided to ensure the return values of these calls are checked for errors to prevent incomplete DWARF generation.

NULL, NULL, NULL, NULL, &cu_die, &err) != DW_DLV_OK)
return;
dwarf_add_AT_name_a(cu_die, (char *)srcname, &err);
dwarf_add_AT_name_a(cu_die, (char *)srcname, &attr_out, &err);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The return value of dwarf_add_AT_name_a is not checked. If this call fails, the compilation unit DIE will be created without a name, and the error state in err might be lost or cause issues in subsequent calls. It is recommended to check the return value for DW_DLV_OK, consistent with the error handling for dwarf_new_die_a and dwarf_add_die_to_debug_a.

	if(dwarf_add_AT_name_a(cu_die, (char *)srcname, &attr_out, &err) != DW_DLV_OK)
		return;

cu_die, NULL, NULL, NULL,
&func_die, &err) == DW_DLV_OK)
dwarf_add_AT_name_a(func_die, fname, &err);
dwarf_add_AT_name_a(func_die, fname, &attr_out, &err);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The return value of dwarf_add_AT_name_a is ignored here. If adding the function name fails, the subprogram DIE will be incomplete. Consider adding a check to handle potential errors, similar to the check for dwarf_new_die_a.

func_die, NULL, NULL, NULL,
&param_die, &err) == DW_DLV_OK)
dwarf_add_AT_name_a(param_die, pname, &err);
dwarf_add_AT_name_a(param_die, pname, &attr_out, &err);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The return value of dwarf_add_AT_name_a is ignored for formal parameters. Checking the return value ensures that the parameter names are correctly added to the DWARF information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants